import Cookies from "js-cookie";

const TokenKey = "token";
const NameKey = "userInfo";

export function getToken() {
  return Cookies.get(TokenKey);
}

export function setToken(token) {
  return Cookies.set(TokenKey, token);
}

export function removeToken() {
  return Cookies.remove(TokenKey);
}

export function getUser() {
  try {
    const user = Cookies.get(NameKey);
    return JSON.parse(user);
  } catch (error) {
    return {}
  }
}

export function setUser(name) {
  return Cookies.set(NameKey, name);
}

export function removeUser() {
  return Cookies.remove(NameKey);
}

